package com.example.hellomap.model;

import java.util.Calendar;

public class Date {
	private int year;
	private int month;
	private int day;
	
	public Date(){
		Calendar c = Calendar.getInstance();
        year = c.get(Calendar.YEAR);
		month = c.get(Calendar.MONTH);
		day = c.get(Calendar.DAY_OF_MONTH);
	}
	
	public Date(int y, int m, int d){
		this.year = y;
		this.month = m;
		this.day = d;
	}
	
	public Date(String d){
		//1912-06-22T22:00:00.000Z
		String[] tokens = d.split("T");
		String[] datum = tokens[0].split("-");
		this.year = Integer.parseInt(datum[0]);
		this.month = Integer.parseInt(datum[1]) - 1;
		this.day = Integer.parseInt(datum[2]);
	}

	public int getYear() {
		return year;
	}

	public void setYear(int year) {
		this.year = year;
	}

	public int getMonth() {
		return month;
	}

	public void setMonth(int month) {
		this.month = month;
	}

	public int getDay() {
		return day;
	}

	public void setDay(int day) {
		this.day = day;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + day;
		result = prime * result + month;
		result = prime * result + year;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Date other = (Date) obj;
		if (day != other.day)
			return false;
		if (month != other.month)
			return false;
		if (year != other.year)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Date [year=" + year + ", month=" + month + ", day=" + day + "]";
	}
	
	
}
